﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Calculalouca
{
    class Buttoncs
    {
        Texture2D texture;
        Point position, size;
        bool clicked = false;
        public bool released = false;

        int buttonPressed = 0;
        int buttonSobMouse = 0;
        //retangulo das opções.
        Rectangle[] retangulos;
        
        public Buttoncs(Texture2D texture, Point position, Point size)
        {
            this.texture = texture;
		    this.position = position;
            this.size = size;

            retangulos = new Rectangle[2];

            for (int y = 0; y < retangulos.Length; y++)
            {
                retangulos[y] = new Rectangle(25 + y * 100, 332, 20, 20);
            }
	    }
	    public void Update()
	    {
            MouseState mouse = Mouse.GetState();
    
		    if (new Rectangle(position.X, position.Y, size.X, size.Y).Contains(mouse.X, mouse.Y))
		    {
			    if (mouse.LeftButton == ButtonState.Pressed)
			    	clicked = true;
                if (clicked == true && mouse.LeftButton == ButtonState.Released)
                {
                    clicked = false;
                    released = true;
                }
		    }

            for (int y = 0; y < retangulos.Length; y++)
            {
                if (retangulos[y].Contains(mouse.X, mouse.Y))
                {
                    buttonSobMouse = y;
                    if (mouse.LeftButton == ButtonState.Pressed)
                    {
                        buttonPressed = y;
                    }
                }
            }

            switch (buttonPressed)
            {
                case 0:
                    break;

                case 1:
                    break;
            }

	    }

	    public void Draw(SpriteBatch spriteBatch)
	    {
		    spriteBatch.Begin();

            for (int y = 0; y < retangulos.Length; y++)
            {
                if (buttonPressed == y)
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.Red);
                }
                else if (buttonSobMouse == y)
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.Yellow);
                }
                else
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.White);
                }
            }

            spriteBatch.Draw(texture, new Rectangle(position.X, position.Y, size.X, size.Y), Color.White);
            spriteBatch.End();
	    }
	
}
}
